home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / efun / previous_object < prev    next >
Text File  |  2001-08-06  |  1KB  |  41 lines

  1. SYNOPSIS
  2.         object previous_object()
  3.         object previous_object(int i)
  4.  
  5. DESCRIPTION
  6.         Returns an object pointer to the object that did a
  7.         call_other() to the current object, if any. If that object
  8.         is destructed, the function returns 0.
  9.  
  10.         If the optional arg is given, the call_other()s are followed
  11.         back i times (i.e. previous_object(2) returns the caller of
  12.         the caller). 0 <= i <= caller_stack_depth()-1
  13.  
  14.         There is an important special case: in functions called by
  15.         the gamedriver in reaction to some external event (e.g. commands
  16.         added by add_action), previous_object() will return this_object(),
  17.         but previous_object(0) will return 0.
  18.  
  19. EXAMPLE
  20.         int security() {
  21.            object prev;
  22.            if(!(prev=previous_object()));
  23.            else if(getuid(prev)!=getuid(this_object()));
  24.            else if(geteuid(prev)!=geteuid(this_object()));
  25.            else return 1;
  26.            return 0;
  27.         }
  28.         void high_sensible_func() {
  29.            if(!security())
  30.               return;
  31.            ...
  32.         }
  33.         
  34.         This example shows how we can check if the last call to a
  35.         function of the current object is secure or if we should abort
  36.         execution.
  37.  
  38. SEE ALSO
  39.         call_other(E), this_object(E), this_player(E),
  40.         caller_stack(E), caller_stack_depth(E), extern_call(E)
  41.